/**
 * Copyright (c) 华南农业大学信息学院蔡超敏2015版权所有
 * 
 * 文件创建时间：2015年4月22日
 */
package org.scauinfo.fpos.service.impl;

import java.io.Serializable;
import java.util.List;

import org.scauinfo.fpos.dao.impl.SaleorderDao;
import org.scauinfo.fpos.service.SaleorderService;
import org.scauinfo.fpos.vo.Saleorder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 蔡超敏
 *
 */
@Service
public class SaleorderServiceImpl implements SaleorderService{

	@Autowired
	private SaleorderDao saleorderDao;

	@Override
	public void saveSaleorder(Saleorder saleorder) {
		saleorderDao.save(saleorder);
	}

	@Override
	public void updateSaleorder(Saleorder saleorder) {
		saleorderDao.update(saleorder);
	}

	@Override
	public void deleteSaleorder(int id) {
		Saleorder saleorder = saleorderDao.get(id);
		saleorder.setUser(null);
		saleorder.setMember(null);
		saleorderDao.delete(saleorder);
	}

	@Override
	public List<Saleorder> findAllSaleorder(int page, int rows,
			String sort, String order) {
		return saleorderDao.findAll(page, rows, sort, order);
	}

	@Override
	public int getTotal() {
		return saleorderDao.countAll();
	}

	@Override
	public boolean isExist(String SaleorderId) {
		boolean flag = false;
		String hql = "from Saleorder as p where p.SaleorderId="
				+ SaleorderId;
		if (saleorderDao.find(hql).size() > 0) {
			flag = true;
		}
		return flag;
	}

	@Override
	public List<Saleorder> findAllSaleorder() {
		return saleorderDao.findAll();
	}

	@Override
	public Saleorder get(Serializable id) {
		return saleorderDao.get(id);
	}

	/* (non-Javadoc)
	 * @see org.scauinfo.fpos.service.SaleorderService#findAllSaleorder(java.lang.String, java.lang.String, java.lang.String, int, int, java.lang.String, java.lang.String)
	 */
	@Override
	public List<Saleorder> findAllSaleorder(String memberId, String begindate,
			String enddate, int page, int rows, String sort, String order) {
		return saleorderDao.findAllSaleorder(memberId, begindate, enddate, page, rows, sort, order);
	}

	/* (non-Javadoc)
	 * @see org.scauinfo.fpos.service.SaleorderService#findAllSaleorder(java.lang.String, java.lang.String, java.lang.String)
	 */
	@Override
	public List<Saleorder> findAllSaleorder(String memberId, String begindate,
			String enddate) {
		return saleorderDao.findAllSaleorder(memberId, begindate, enddate);
	}

}
